class_name HoldGunRocketLauncher
extends BaseHoldItem

@onready var muzzle: Marker2D = $Muzzle
@onready var muzzle_in_shape_tester: Area2D = $MuzzleInShapeTester


func shoot():
	if muzzle_in_shape_tester.get_overlapping_bodies().size() > 0: return
	
	var player = holder as Player
	var config = item_data.item_config as ItemBaseConfig
	
	var bullet_inst = (ResourceManager.get_resource("particle_tank_missle") as PackedScene).instantiate() as ParticleTankMissle
	player.level.bullets_parent.add_child(bullet_inst)
	bullet_inst.set_is_enemy(false)
	
	bullet_inst.global_position = muzzle.global_position
	bullet_inst.dir = Vector2.from_angle(player.gun_hand.global_rotation) 
	bullet_inst.speed = 80
	bullet_inst.life_time = 5.0
	bullet_inst.sender = player
	bullet_inst.attack = config.attack + player.player_data.get_attack()
	bullet_inst.critical_rate = config.critical_rate
	bullet_inst.critical_bonus = config.critical_bonus
	bullet_inst.knockback = config.knockback
	bullet_inst.hit_cam_shake_strength = config.attack_cam_shake_intensity
	bullet_inst.hit_cam_shake_duration = config.attack_cam_shake_duration
